package com.jdls.service.Impl;

import com.jdls.dao.AccountDao;
import com.jdls.service.AccountService;
import com.jdls.service.LogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class AccountServiceImpl implements AccountService {
    @Autowired
    private AccountDao accountDao;
    @Autowired
    private LogService logService;

    public void transfer(String out,String in ,Double money) {
        boolean a = true;
        try{
            accountDao.outMoney(out,money);
            int i = 1/0;
            accountDao.inMoney(in,money);
        }catch (Exception e){
            a=false;
        }finally {
            if (a){
                in = in+"->成功转账";
                logService.log(out,in,money);
            }else {
             in = in+"->失败转账";
             logService.log(out,in,money);
            }
        }
    }
}